<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-body">
	<table class="table">
		<tbody>
			<tr>
				<td style="width: 280px; vertical-align: top;padding-left: 0;">
					<ul id="ztree_ul" class="ztree"></ul>
					#if(!readonly && com.yj.auto.helper.AuthHelper::auth("doc/index", "type", session.SESSION_USER))
					<button type="button" class="btn btn-link auto-btn auto-load" data-uri="docType/index" data-target="worker" style="float: right;"><i class="fa fa-reorder"></i>&nbsp;分类管理</a></button>
					#end
				</td>
				<td style="vertical-align: top;padding-top:10px">
					<div class="box box-solid">
						<div class="box-header no-padding">
							<form id="auto-query-form" class="form-inline" method="post" role="form">
								<div class="form-group">
									<label class="control-label" for="query.keyword">关键字</label>
									<input id="query.keyword" name="query.keyword" placeholder="请输入关键字" class="form-control"/>
									<input id="query.type" name="query.type" value="" type="hidden">
									<input id="temp.typeName" name="temp.typeName" value="" type="hidden">
								</div>
								#if(readonly)
								<input id="query.state" name="query.state" value="01" type="hidden">
								#else
								<div class="form-group">
									<label class="control-label" for="query.state">有效性</label>
									#@dict_select("query.state","01","DATA_STATE",true,"有效性","")
								</div>
								#end
								<div class="form-group">
									#@query_btn()
								</div>
							</form>
						</div>
				
						<div class="box-body no-padding">
							<table id="auto_data_table" data-form-width="900" class="table table-striped table-hover table-bordered dataTable no-footer" width="100%">
							</table>
						</div>
						#if(!readonly)
						<div id="doc_tools" class="box-footer text-center " style="display: none;">
							#@add_btn("doc/index",true)
							#@edit_btn("doc/index",true)
							#@del_btn("doc/index",true)
						</div>
						#end
					</div>
				</td>
			</tr>
		</tbody>
	</table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
	var ztree_id = "ztree_ul";
	$(document).ready(function() {
		var dtColumns=[
			   { "data" : "title", "name" : "title", "title" : "标题" },
			   { "data" : "type_id", "name" : "type_id", "title" : "知识分类" , "render" : function(data, type, row) {
	                return row.type_name;
	            }},
			   { "data" : "ltime", "name" : "ltime", "title" : "最后编辑日期" ,render : function(data, type, row, meta) {
	                return dateConvert(data,"yyyy-mm-dd hh:ii");
	            } },
			   { "data" : "luser", "name" : "luser", "title" : "最后编辑人", "render" : function(data, type, row) {
	                return row.user_name;
	            }}
			];

		var _ztreeSetting = {
			data : {
				simpleData : {
					enable : true
				}
			},
			async : {
				enable : true,
				url : "docType/children",
				autoParam : [ "id" ],
				otherParam : { "state":"01"}
			},
			callback : {
				onClick : function (event, treeId, treeNode) {
					jid("query.type").val(treeNode.id);
					jid("temp.typeName").val(treeNode.name);
					$("#doc_tools").show();
					$("#query_btn").trigger("click");
				}
			}
		};
		#if(!readonly)
			dtColumns.push({ "data" : "state", "name" : "state", "title" : "状态", "render" : function(data, type, row) {
                return dict_name("DATA_STATE",data);
            } });
			_ztreeSetting.async.otherParam = null;
		#end
		$.fn.zTree.init($("#" + ztree_id), _ztreeSetting);	
		
		$('#auto_data_table').autoDataTable({
			controller : "doc",
			title : "知识库",
			columns : dtColumns
		});
		
	});
	
</script>
